home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Development Tools & Languages / Dylan Related / Mindy-1.1 (sources only) / mindy-1.1 / interp / parser.y < prev    next >
Encoding:
Text File  |  1994-06-28  |  2.6 KB  |  103 lines  |  [TEXT/ttxt]

  1. /**********************************************************************\
  2. *
  3. *  Copyright (c) 1994  Carnegie Mellon University
  4. *  All rights reserved.
  5. *  
  6. *  Use and copying of this software and preparation of derivative
  7. *  works based on this software are permitted, including commercial
  8. *  use, provided that the following conditions are observed:
  9. *  
  10. *  1. This copyright notice must be retained in full on any copies
  11. *     and on appropriate parts of any derivative works.
  12. *  2. Documentation (paper or online) accompanying any system that
  13. *     incorporates this software, or any part of it, must acknowledge
  14. *     the contribution of the Gwydion Project at Carnegie Mellon
  15. *     University.
  16. *  
  17. *  This software is made available "as is".  Neither the authors nor
  18. *  Carnegie Mellon University make any warranty about the software,
  19. *  its performance, or its conformity to any specification.
  20. *  
  21. *  Bug reports, questions, comments, and suggestions should be sent by
  22. *  E-mail to the Internet address "gwydion-bugs@cs.cmu.edu".
  23. *
  24. ***********************************************************************
  25. *
  26. * $Header: parser.y,v 1.7 94/06/27 16:32:29 wlott Exp $
  27. *
  28. * This file is the parser for the debugger.
  29. *
  30. \**********************************************************************/
  31.  
  32. %{
  33. #include "mindy.h"
  34. #include "parser.h"
  35. #include "list.h"
  36. #include "sym.h"
  37. #include "bool.h"
  38. #include "lexer.h"
  39.  
  40. static void yyerror(char *);
  41.  
  42. static obj_t result;
  43.  
  44. %}
  45.  
  46. %token tok_ERROR
  47. %token tok_LPAREN
  48. %token tok_RPAREN
  49. %token tok_DEBUGVAR
  50. %token tok_ARG
  51. %token tok_LITERAL
  52. %token tok_SYMBOL
  53. %token tok_KEYWORD
  54. %token tok_COMMA
  55.  
  56. %%
  57.  
  58. start:        exprlist            { result = $1; }
  59.     |    /* epsilon */            { result = obj_Nil; }
  60. ;
  61.  
  62. exprlist:    expr                { $$ = list1($1); }
  63.     |    expr tok_COMMA exprlist        { $$ = pair($1, $3); }
  64. ;
  65.  
  66. expr:        leaf                { $$ = $1; }
  67.     |    expr tok_LPAREN tok_RPAREN
  68.             { $$ = list2(symbol("funcall"), $1); }
  69.     |    expr tok_LPAREN arglist tok_RPAREN
  70.             { $$ = pair(symbol("funcall"), pair($1, $3)); }
  71. ;
  72.  
  73. leaf:        tok_DEBUGVAR        { $$ = pair(symbol("debug-var"), $1); }
  74.     |    tok_ARG            { $$ = pair(symbol("arg"), $1); }
  75.     |    tok_LITERAL        { $$ = pair(symbol("literal"), $1); }
  76.     |    tok_KEYWORD        { $$ = pair(symbol("literal"), $1); }
  77.     |    tok_SYMBOL        { $$ = pair(symbol("variable"),$1); }
  78. ;
  79.  
  80. arglist:    expr more_args            { $$ = pair($1, $2); }
  81.     |    tok_KEYWORD expr more_args
  82.             { $$ = pair(pair(symbol("literal"),$1),pair($2, $3)); }
  83. ;
  84.  
  85. more_args:    /* epsilon */            { $$ = obj_Nil; }
  86.     |    tok_COMMA arglist        { $$ = $2; }
  87. ;
  88.  
  89. %%
  90.  
  91. static void yyerror(char *msg)
  92. {
  93. }
  94.  
  95. obj_t parse_exprs()
  96. {
  97.     if (yyparse())
  98.     return obj_False;
  99.     else
  100.     return result;
  101. }
  102.  
  103.